/*
 * migrarcuentascontables.java
 *
 * Created on 23 de agosto de 2007, 13:32
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package utiles;
import java.sql.*;  
 import java.io.*;  
 import com.hxtt.sql.*;
 import java.rmi.*;
 import java.rmi.registry.*;
 import java.rmi.registry.LocateRegistry;
/**
 *
 * @author admin
 */
public class migrarcuentascontables {
    funcioncliente.FuncionesControlAcceso fca;
    String conexao = "com.hxtt.sql.dbf.DBFDriver"; 
    utiles.ModificableTableModel modelo;
    Statement stmt;
    Connection conn;
    DatosTablaDBF dbb;
    utiles.conexionRmiJdbc conex;
     ResultSet result;
    /** Creates a new instance of migrarcuentascontables */
    public migrarcuentascontables() {
         try{
            
        System.setProperty("java.security.policy", "c:/pruebaRMI/java.policy");
        System.setProperty ("java.rmi.server.codebase","http://192.168.23.6/");
        
        if (System.getSecurityManager() == null){
 		System.setSecurityManager(new RMISecurityManager());
 		}
            fca=( funcioncliente.FuncionesControlAcceso)java.rmi.Naming.lookup("//192.168.23.6:1234/rmi");
                  
            
        }catch(Exception e){
            e.printStackTrace();
        }
           try{
            Class.forName(conexao).newInstance();
            String url = "jdbc:DBF:/c:/dbf/";
            conn = DriverManager.getConnection(url);
            stmt = conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,
                                                          java.sql.ResultSet.CONCUR_UPDATABLE);
        }catch(Exception e){}
        conex=new utiles.conexionRmiJdbc("192.168.23.6","SQL2005","RecursosHumanos","administrador","administrador1234",true);
        mig();
    
    }
    
    void mig(){
        try{    
            
            result=stmt.executeQuery("select CCTA,DESC  from PLANCTAS");
            result.last();
            int num=result.getRow();
    
            String par1=null,par2=null;
            for(int i=0;i<num;i++){
                result.absolute(i+1);
                try{
                    par1=result.getString(1).trim();
                }catch(Exception e1){
                    System.out.println("en param1  ");
                    e1.printStackTrace();
                }
                  try{
                    par2=result.getString(2).trim();
                }catch(Exception e2){
                    System.out.println("en param2  ");
                    e2.printStackTrace();
                }
                
               /* PreparedStatement pstmt = conex.conexion.prepareStatement("insert into cuenta_contable" +
                        " (id_cuenta_contable,desc_cuenta) values (?,?)");
                pstmt.setString(1,par1);
                pstmt.setString(2,par2);
                pstmt.executeUpdate();
                pstmt.close();
                conex.conexion.commit();*/
                
                
            //fca.migrarconta(par1,par2);
            }
            
            result.close();
        }catch(Exception efg){
            System.out.println("en RMi  ");
            efg.printStackTrace();
        }
    }
    
    
    public static void main(String args[]){
        new  migrarcuentascontables();
    }
    
}
